<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
	version="1.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:output method="xml"/> 
	
	<xsl:param name="documentoA" select="'transformacion_graph_2.xsl'"/>
	 
	<xsl:template match="/*">
	<xsl:variable name="vDeep-equal"> 
	<xsl:apply-templates select="." mode="deep-equal"> 
	<xsl:with-param name="documentoB" select="document($documentoA)/*"/> 
	</xsl:apply-templates> 
	</xsl:variable> 
	<xsl:choose> 
	<xsl:when test="normalize-space($vDeep-equal)"> 
	<xsl:text>Los documentos son DIFERENTES</xsl:text> 
	</xsl:when> 
	<xsl:otherwise> 
	<xsl:text>Los documentos son exactamente IGUALES</xsl:text> 
	</xsl:otherwise> 
	</xsl:choose> 
	</xsl:template> 
	<xsl:template match="*" mode="deep-equal"> 
	<xsl:param name="documentoB"/> 
	<xsl:choose> 
	<xsl:when test="$documentoB/self::* and local-name()=local-name($documentoB) and namespace-uri()=namespace-uri($documentoB) and count(@*)=count($documentoB/@*) and count(*|text()[normalize-space()]) = count($documentoB/*| $documentoB/text()[normalize-space()])"> 
	<xsl:for-each select="@*"> 
	<xsl:if test="$documentoB/@*[name()=name(current())] != ."> 
	<xsl:text>false</xsl:text> 
	</xsl:if> 
	</xsl:for-each> 
	<xsl:for-each select="*|text()[normalize-space()]"> 
	<xsl:variable name="vPosition" select="position()"/> 
	<xsl:apply-templates select="." mode="deep-equal"> 
	<xsl:with-param name="documentoB" select="($documentoB/*| $documentoB/text() [normalize-space()]) [$vPosition]"/> 
	</xsl:apply-templates> 
	</xsl:for-each> 
	</xsl:when> 
	<xsl:otherwise>false</xsl:otherwise> 
	</xsl:choose>
	 </xsl:template> 
	 <xsl:template match="text()" mode="deep-equal"> 
	 <xsl:param name="documentoB"/> 
	 <xsl:if test="not($documentoB/self::text() and string() = string($documentoB))"> 
	 <xsl:text>false</xsl:text> 
	 </xsl:if> 
	 </xsl:template> 
 </xsl:stylesheet>